from manim import *


class dotMovetoCurve(Scene):
    def construct(self):
        ax = Axes(
            x_range=[0, 10],
            y_range=[0, 10],
            x_length=6,
            y_length=6,
        )
        k = 10
        def func(x):
            # print(f"x={x}")
            return k / x

        graph = ax.plot(
            func,
            color=YELLOW,
            x_range=[1, 10.0, 0.1],
            use_smoothing=False,
        )
        self.add(ax, graph)

        # 点 延曲线移动
        t = ValueTracker(1)
        dot = Dot()
        dot.add_updater(lambda x: x.move_to(ax.c2p(t.get_value(), k / t.get_value())))
        dot.set_z_index(1)

        self.play(Create(dot))
        self.play(t.animate.set_value(10), run_time=5)
        self.wait()
